#!/bin/bash

# 安装nginx
# sudo apt update
# sudo apt install -y nginx

# 配置nginx转发FTP服务
cat <<EOL | sudo tee /etc/nginx/conf.d/ftp_proxy.conf
server {
    listen 2121;
    server_name localhost;

    location / {
        proxy_pass ftp://10.146.84.20:21;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto \$scheme;
    }
}
EOL

# 测试nginx配置
sudo nginx -t

# 重启nginx服务以应用新配置
sudo systemctl restart nginx

echo "Nginx已配置为转发FTP服务，地址为10.146.84.20:21"